﻿Public Class Settings

    Private Sub Settings_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        My.Settings.Reload()
        txtDataSource.Text = My.Settings.DataSource
        txtdominopassword.Text = My.Settings.DominoPassword
        txtdominoserver.Text = My.Settings.DominoServer
        txtdominouser.Text = My.Settings.DominoAccountFile
        cbDomioSaveMessage.Checked = My.Settings.DominoSaveOnSend

        Me.Text = "Settings"
        Button1.Enabled = False
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        SaveSettings()
    End Sub
    Sub SaveSettings()
        My.Settings.DataSource = txtDataSource.Text
        My.Settings.DominoPassword = txtdominopassword.Text
        My.Settings.DominoServer = txtdominoserver.Text
        My.Settings.DominoAccountFile = txtdominouser.Text
        My.Settings.DominoSaveOnSend = cbDomioSaveMessage.Checked

        My.Settings.Save()
        Button1.Enabled = False
        Me.Text = "Settings"
    End Sub
    Private Sub Settings_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
        If Me.Text.Contains("*") Then
            Dim a = MsgBox("Do you want to save modified settings?", MsgBoxStyle.YesNoCancel)
            If a = MsgBoxResult.Yes Then
                SaveSettings()
            End If
        End If
    End Sub

    Private Sub txtDataSource_TextChanged(sender As Object, e As EventArgs) Handles txtDataSource.TextChanged, txtdominopassword.TextChanged, txtdominoserver.TextChanged, txtdominouser.TextChanged
        PutStar()
    End Sub
    Sub PutStar()
        If Me.Text.Contains("*") = False Then
            Me.Text = Me.Text & "*"
            Button1.Enabled = True
        End If
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
End Class